package com.ostrich.cloud.ostrichManagerWeb.app.controller;

import cn.hutool.core.bean.BeanUtil;
import com.ostrich.cloud.common.result.PageResult;
import com.ostrich.cloud.common.result.Result;
import com.ostrich.cloud.ostrichGoodsSercice.model.Dto.GoodsDto;
import com.ostrich.cloud.ostrichGoodsSercice.model.param.CreateGoodsParam;
import com.ostrich.cloud.ostrichGoodsSercice.model.param.GetGoodsParam;
import com.ostrich.cloud.ostrichGoodsService.client.GoodsClient;
import com.ostrich.cloud.ostrichManagerWeb.client.GoodsWebManagerClient;
import com.ostrich.cloud.ostrichManagerWeb.client.param.GetGoodsOnly;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;


@RestController
public class GoodsManagerApiImp implements GoodsWebManagerClient {

    @Resource
    private GoodsClient goodsClient;



    @Override
    public Result getGoodsOnly(@Valid GetGoodsOnly getGoodsOnly) {
        GetGoodsParam getGoodsParam = BeanUtil.copyProperties(getGoodsOnly, GetGoodsParam.class);
        PageResult<GoodsDto> goodsByCriteria = goodsClient.getGoodsByCriteria(getGoodsParam);

        return goodsByCriteria;
    }

    @Override
    public Result getAllGoods(Integer current, Integer size) {
        PageResult<GoodsDto> allGoods = goodsClient.getAllGoods(current, size);
        return allGoods;


    }
}
